# -*- coding: utf-8 -*-
from zinx.ziface.irouter import IRouter
from zinx.ziface.iconnection import IConnection
from zinx.ziface.iconmanager import IConManager
from abc import ABC, abstractmethod


class IServer(ABC):
    """
    定义服务器接口
    """
    @abstractmethod
    def Start(self):
        """
        启动服务器方法
        :return:
        """
        pass

    @abstractmethod
    def Stop(self):
        """
         停止服务器方法
         :return:
         """
        pass

    @abstractmethod
    def Serve(self):
        """
        开启业务服务方法
        :return:
        """
        pass

    @abstractmethod
    def AddRouter(self, msgID: int, router: IRouter):
        """
        添加路由
        :param router:
        :return:
        """
        pass

    @abstractmethod
    def GetConnMgr(self) -> IConManager:
        """
        得到链接管理
        :return:
        """
        pass

    @abstractmethod
    def SetOnConnStart(self, cb):
        """
        设置该Server的连接创建时Hook函数
        :param cb:
        :return:
        """
        pass

    @abstractmethod
    def SetOnConnStop(self, cb):
        """
        设置该Server的连接断开时的Hook函数
        :param cb:
        :return:
        """
        pass

    @abstractmethod
    def CallOnConnStart(self, conn: IConnection):
        """
        调用连接OnConnStart Hook函数
        :param conn:
        :return:
        """
        pass

    @abstractmethod
    def CallOnConnStop(self, conn: IConnection):
        """
        调用连接OnConnStop Hook函数
        :param conn:
        :return:
        """
        pass